package com.ruoyi.finances.until;

/**
 * @author: liufei
 * @Desc:
 * @create: 2024-11-14 15:43
 **/

public class R {

    private String msg;

    private Object data;

    private Integer code;

    private Boolean flag;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

    public static R success(Object data){
        R r = new R();
        r.setFlag(true);
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(data);
        return r;
    }

    public static R ok(){
        R r = new R();
        r.setFlag(true);
        r.setCode(200);
        r.setMsg("操作成功");
        return r;
    }

    public static R error(){
        R r = new R();
        r.setFlag(false);
        r.setCode(500);
        r.setMsg("操作失败");
        return r;
    }

    public static R error(String msg){
        R r = new R();
        r.setFlag(false);
        r.setCode(500);
        r.setMsg(msg);
        return r;
    }
}
